<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core">

<ui:composition template="/templates/interna.xhtml">

	<ui:define name="titulo">
    	Cadastro de Familias
	</ui:define>

	<ui:define name="corpo">
		<h:form id="cadastro">
			<h:messages />
			<h:inputHidden value="#{familiaBean.familia.id}" />
			<h:inputHidden value="#{familiaBean.destinoSalvar}" />

			<h:panelGrid columns="2">
				<h:outputLabel value="Nome:" for="nome" />
				<h:inputText id="nome" label="Nome"
					value="#{familiaBean.familia.name}" size="30" maxlength="30"
					required="true" requiredMessage="Você não tem nome?">
					<f:validateLength minimum="10" maximum="30" />
				</h:inputText>
				
				<h:outputLabel value="Endereço" for="endereco" />	
				<h:inputTextarea id="endereco" label="Endereco" value="#{familiaBean.familia.endereco}"
					required="true" requiredMessage="Endereço da família é obrigatório">
					<f:validateLength minimum="10" maximum="255"/>
				</h:inputTextarea>			

				<h:outputLabel value="Celular:" for="celular" />
				<h:inputText id="celular" label="Celular"
					value="#{familiaBean.familia.celular}" size="10" />
				
				<h:outputLabel value="Telefone" for="telefone" />
				<h:inputText id="telefone" label="Telefone"
					value="#{familiaBean.familia.telefone}" size="10" />

				<h:outputLabel value="e-Mail:" for="email" />
				<h:panelGroup>
					<h:inputText id="email" label="e-Mail"
						value="#{familiaBean.familia.email}" size="50" maxlength="50"
						required="true" validatorMessage="e-Mail inválido">
						<f:validateRegex pattern="[a-zA-Z0-9\-\_\.]+@[a-zA-Z0-9\-\_\.]+" />
					</h:inputText>
					<h:message for="email" />
				</h:panelGroup>
			</h:panelGrid>
			
			<h:panelGroup rendered="#{!empty familiaBean.carregaMestreFamiliares}">
				<fieldset>
					<legend>Mestre Familiar</legend>
					<h:panelGrid columns="2">
						<h:outputLabel value="Nome da Dupla " for="nomeDupla" />
						<h:inputText value="#{familiaBean.mestresFamiliares.nomeDupla}"
							required="true" id="nomeDupla" maxlength="45" requiredMessage="Está faltando o nome da Dupla!" />

						<h:outputLabel value="Companheiro A: " for="companheiro" />
						<h:inputText value="#{familiaBean.mestresFamiliares.integrante_a}" size="20"
							id="companheiro" required="true" maxlength="60"
							requiredMessage="Nome do integrante da dupla de Mestres está faltando!">
						</h:inputText>
						
						<h:outputLabel value="Companheiro B: " for="companheiroB" />
						<h:inputText value="#{familiaBean.mestresFamiliares.integrante_b}" size="20"
							id="companheiroB" required="true" maxlength="60"
							requiredMessage="Nome do integrante da dupla de Mestres está faltando!">
						</h:inputText>
					</h:panelGrid>
				</fieldset>
			</h:panelGroup>

			<h:commandButton action="#{familiaBean.salvar}" value="Salvar" />
		</h:form>
	</ui:define>
</ui:composition>
</html>
